package com.lala.rennigou.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lala.rennigou.mapper.EasybuyNewsMapper;
import com.lala.rennigou.pojo.EasybuyNews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EasybuyNewsServiceImpl implements EasybuyNewsService{

    @Autowired
    private EasybuyNewsMapper easybuyNewsMapper;

    @Override
    public List<EasybuyNews> selectByTime() {
        return easybuyNewsMapper.selectByTime();
    }

    @Override
    public PageInfo<EasybuyNews> fenye(int pagenum, int pagesize) {
        PageHelper.startPage(pagenum,pagesize);
        PageInfo<EasybuyNews> pageInfo =new PageInfo<>(easybuyNewsMapper.fenyeNews());
        //pageInfo.setNavigatePages(4);
        return pageInfo;
    }

    @Override
    public int addzixun(EasybuyNews easybuyNews) {
        return easybuyNewsMapper.insert(easybuyNews);
    }

    @Override
    public int deletezixun(int id) {
        return easybuyNewsMapper.deleteById(id);
    }

    @Override
    public int updatezixun(EasybuyNews easybuyNews) {
        return easybuyNewsMapper.updateById(easybuyNews);
    }

    @Override
    public int newsByTT(String title) {
        return easybuyNewsMapper.newsByTT(title);
    }
}
